package com.sl;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;

import javax.rmi.CORBA.Stub;

public class Test02 {
	public static void main(String[] args)throws Exception{
	   Test01 obj = new Test01("张三", 19, 100f);
	   Test01.setSchool("华男大学");
	   System.out.println(obj);
	   File file = new File("E:\\PR");
		try(
			OutputStream out = new FileOutputStream(file);
			ObjectOutputStream oout = new ObjectOutputStream(out);	
				){
			oout.writeObject(oout);
			
		}
		//使用序列化技术完成对象克隆
//		try(
//				ByteArrayOutputStream out = new ByteArrayOutputStream();
//				ObjectOutputStream oout = new ObjectOutputStream(out);	
//					){
//				oout.writeObject(oout);
//				try(
//					ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());	
//					ObjectInputStream oin = new ObjectInputStream();
//							){
//					Object obj = oin.readObject();
//					System.out.println(obj);
//					
//				}
//			}
	}
}
